//
// Created by xili on 2024/8/7 18:59.
// Go big or go home.
//
#include <vector>
#include <map>

using namespace std;

class Solution {
public:
    vector<vector<int>> mergeArrays(vector<vector<int>> &nums1, vector<vector<int>> &nums2) {
        map<int, int> ump;
        for (auto &item: nums1) {
            ump[item[0]] += item[1];
        }
        for (auto &item: nums2) {
            ump[item[0]] += item[1];
        }
        int i = 0;
        vector<vector<int>> ans;
        for (auto &[id, sum]: ump) {
            ans.push_back({id, sum});
        }
        return ans;
    }
};